#include <iostream>
// #include <sstream>
#include <bitset>

template<uint8_t opcode_len>
using Opcode = std::bitset<opcode_len>;

using namespace std;

std::pair<Opcode<7>, Opcode<5>> split_offset(Opcode<12> offset)
{
  return std::make_pair(Opcode<7>{offset.to_string().substr(5,7)}, Opcode<5>{offset.to_string().substr(0,5)});
  cout << offset << endl;
  Opcode<5> imm5 {offset.to_string().substr(0,5)};
  Opcode<7> imm7 {offset.to_string().substr(5,7)};
  cout << imm5 << " and " << imm7 << endl;
  return std::make_pair(imm7, imm5);
}

int main()
{
    // split_offset(0b101110000010);
    cout << Opcode<12>(2946) << endl;
    auto [imm7, imm5] = split_offset(2946);
    cout << imm5 << " and " << imm7 << endl;
    return 0;
}
